package com.shiro.token;

import java.util.Map;

import org.apache.shiro.authc.AuthenticationToken;

/**
 * 无状态Token
 * 逻辑：
 * 1、无状态应用登录使用
 * 2、实现AuthenticationToken
 * 3、Principal:username
 * 4、Credential:clientDigest
 * 
 * @author Eason
 *
 */
public class StatelessToken implements AuthenticationToken {

	private static final long serialVersionUID = -4587097865587650224L;

	// token
	private String username;
	
	// 时间戳
	private String sequence;
	
	// params、token、sequence生成的摘要
    private String clientDigest;

	private Map<String, ?> params;

    public StatelessToken(String username,  String sequence, Map<String, ?> params, String clientDigest) {
        this.username = username;
        this.sequence = sequence;
        this.params = params;
        this.clientDigest = clientDigest;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getSequence() {
    	return sequence;
    }
    
    public void setSequence(String sequence) {
    	this.sequence = sequence;
    }
    
    public  Map<String, ?> getParams() {
        return params;
    }

    public void setParams( Map<String, ?> params) {
        this.params = params;
    }

    public String getClientDigest() {
        return clientDigest;
    }

    public void setClientDigest(String clientDigest) {
        this.clientDigest = clientDigest;
    }

    @Override
    public Object getPrincipal() {
       return username;
    }

    @Override
    public Object getCredentials() {
        return clientDigest;
    }


}